package cn.itsource.ymcc.producer;

import cn.itsource.ymcc.constant.PayConstants;
import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class PayProducerImpl implements PayProducer {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;
    @Override
    public void sendEditOrder(Map<String, Object> map) {
        rocketMQTemplate.syncSend(PayConstants.TOPIC_PAY_ORDER_MESSAGE+":"+PayConstants.TAGS_PAY_ORDER_MESSAGE,
                MessageBuilder.withPayload(JSON.toJSONString(map)).build());
    }

    @Override
    public void sendAddUserLearn(Map<String, Object> map) {
        rocketMQTemplate.syncSend(PayConstants.TOPIC_PAY_COURSE_MESSAGE+":"+PayConstants.TAGS_PAY_COURSE_MESSAGE,
                MessageBuilder.withPayload(JSON.toJSONString(map)).build());
    }
}
